﻿using Sino.CapacityCloud.WebApi;
using Sino.Tms.Primitives;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;

namespace Sino.CapacityCloud.Repositories.Models
{

    public class ConfirmedOrder
        : IOrder<ConfirmedOrder>
    {

        [Key()]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public string ConfirmedOrderId { get; set; }

        public string OrderNumber { get; set; }

        public string UserId { get; set; }

        public string CarrierOrderId { get; set; }

        public string TransportLinkageId { get; set; }

        public double Amount { get; set; }

        public string AmountUnit { get; set; }

        public DateTime ArrivalTime { get; set; }

        public string CarCode { get; set; }

        public string CarLength { get; set; }

        public string Category { get; set; }

        public string ContactName { get; set; }

        public string ContactChatId { get; set; }

        public string ContactPhoneNumber { get; set; }

        public DateTime DeliveryTime { get; set; }

        public string GrabComment { get; set; }

        public bool IsFocus { get; set; }

        public string Price { get; set; }

        public int DrawableCostCount { get; set; }

        public OrderStatus State { get; set; }

        public double Emergency { get; set; }

        public string Remarks { get; set; }

        public OrderType Type { get; set; }

        public virtual TransportLinkage TransportLinkage { get; set; }

        public virtual ApplicationUser User { get; set; }

        public virtual ConfirmedOrder Parent { get; set; }

        public virtual ICollection<ConfirmedOrder> SubOrders { get; set; }

        [NotMapped]
        string IOrder<ConfirmedOrder>.Id
        {
            get
            {
                return this.ConfirmedOrderId;
            }
            set
            {
                this.ConfirmedOrderId = value;
            }
        }

        public ConfirmedOrder()
        {
            this.ConfirmedOrderId = Guid.NewGuid().ToString();
            this.SubOrders = new List<ConfirmedOrder>();
        }

    }

}